<!--
 * @Author: hucc
 * @Date: 2021-10-11 17:04:24
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-11 20:11:35
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>重构element ui按钮</title>
    <script src="../js/vue.js"></script>
    <style>
        button {
            width: 100px;
            height: 40px;
            color: #fff;
            font-size: 16px;
            border: none;
            border-radius: 5px;
        }
        
        button:hover {
            cursor: pointer;
        }
        /* button:first-child {
            background-color: #ffffff;
            border: 1px solid #dcdfe6;
            color: #606266;
        }
        
        button:nth-child(2) {
            background-color: #66b1ff;
        }
        
        button:nth-child(3) {
            background-color: #67c23a;
        } */
    </style>
</head>

<body>
    <div id="app">
        <!-- 使用组件 -->
        <el-button>默认按钮</el-button>
        <el-button type="primary">主要按钮</el-button>
        <el-button type="success">成功按钮</el-button>
        <el-button type="info">信息按钮</el-button>
        <el-button type="warning">警告按钮</el-button>
        <el-button type="danger">危险按钮</el-button>

    </div>
    <script>
        //1.定义组件
        let component = {
            props: {
                type: {
                    type: String,
                    default: 'default'
                }
            },
            data() {
                return {
                    obj: {
                        default: {
                            backgroundColor: ' #ffffff',
                            border: '1px solid #dcdfe6',
                            color: ' #606266'
                        },
                        primary: {
                            backgroundColor: '#66b1ff'
                        },
                        success: {
                            backgroundColor: ' #67c23a'
                        },
                        info: {
                            backgroundColor: '#a6a9ad'
                        },
                        warning: {
                            backgroundColor: '#e6a23c'
                        },
                        danger: {
                            backgroundColor: '#f67878'
                        }
                    }
                }
            },
            template: `
               
                <button :style=obj[type]>
                    <slot></slot>
                </button>
               
            `
        }
        new Vue({
            el: '#app',
            data: {
                style1: {
                    color: "black",
                    backgroundColor: "pink"
                }
            },
            methods: {},
            components: {
                //2.局部注册组件
                'el-button': component
            },

        })
    </script>
</body>

</html>